package top.wshape1.shiziapi.common.constant;

import lombok.Getter;

/**
 * @author Wshape1
 * @version 1.0
 * @description
 * @since 2025-01-12
 */

@Getter
public enum DocTypeEnum {

    API(0, "api"),
    MARKDOWN(1, "markdown"),
    RTF(2, "rtf"),
    FOLDER(3, "folder"),
    MIND_MAP(4, "mindmap"),
    ;

    private final int typeInt;
    private final String typeStr;

    DocTypeEnum(int typeInt, String typeStr) {
        this.typeInt = typeInt;
        this.typeStr = typeStr;
    }

    public static DocTypeEnum getDocTypeEnum(Integer typeInt) {
        if (typeInt == null) {
            return null;
        }
        for (DocTypeEnum docTypeEnum : values()) {
            if (docTypeEnum.getTypeInt() == typeInt) {
                return docTypeEnum;
            }
        }
        return null;
    }

    public static DocTypeEnum getDocTypeEnum(String typeStr) {
        for (DocTypeEnum docTypeEnum : values()) {
            if (docTypeEnum.getTypeStr().equals(typeStr)) {
                return docTypeEnum;
            }
        }
        return null;
    }

}
